package com.htfyun.roobofactory.rooboUtils;

import android.content.Context;
import android.util.Log;

import com.iflytek.cloud.Setting;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechUtility;

/**
 * Created by sst on 2018/7/10.
 */

public final class IflytekInit {

    private static final String TAG = "IflytekInit";
    private static boolean hasInit = false;

    public static synchronized void init(Context context) {
        Log.e(TAG, "Init,hasInit = " + hasInit);
        StringBuffer param = new StringBuffer();
        param.append("appid=552cd878").append(",");
        // 设置使用v5+
        param.append(SpeechConstant.ENGINE_MODE + "=" + SpeechConstant.MODE_MSC);
        SpeechUtility.createUtility(context, param.toString());
        Setting.setShowLog(false);
        RooboEngine engine = RooboEngine.getInstance();
        engine.init(context);
        if (hasInit) {
            return;
        }
        hasInit = true;

        if (!IFlytekSoLoader.loadLibrary(context)) {
            Log.e(TAG, "loadLibrary failed");
        } else {
            Log.e(TAG, "loadLibrary success");
        }

    }
}
